package View.Frame;

import java.awt.Container;
import java.awt.Dimension;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Menu;
import java.awt.Toolkit;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;
import javax.swing.JPanel;

import Controller.Game.GamePanelController;
import Controller.Menu.MenuController;

/**
 * This Class is the Frame used in this application
 * @author magal
 *
 */
public class PrincipalFrame extends JFrame{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Toolkit tk_;
	private Dimension panelDimension_;
	private Container contentPane;
	private boolean fullScreen;
	private GamePanelController gamePanelController;
	private MenuController menuController;
	private GraphicsDevice gd;

	

	public PrincipalFrame(){
		setTitle("FirstFrame");
		addWindowListener(new desligaTela());
		tk_ = Toolkit.getDefaultToolkit();
		panelDimension_ = tk_.getScreenSize();
		setSize(800, 600);
		//setBounds(panelDimension_.width, panelDimension_.height,
		//		panelDimension_.width, panelDimension_.height);
		/*panelContainer = this.getContentPane();
		JPanel p = new JPanel();
		panelContainer.add(p);*/
		fullScreen = false;
		gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();

	}
	public class desligaTela extends WindowAdapter {
		public void windowClosing(WindowEvent e){
			if(menuController != null){
				menuController.haltMusic();
			}
			System.exit(0);
		}
	}
	public void activeMenu(){
		
	}
	public void deactiveMenu(){
		
	}
	public void addContentPane(JPanel panel){
		contentPane = this.getContentPane();
		contentPane.add(panel);
	}
	
	//http://gpsnippets.blogspot.com/2007/08/toggle-fullscreen-mode.html
	public void setFullScreen(){
		setVisible(false);
		dispose();
		setUndecorated(true);
		gd.setFullScreenWindow(this);
		repaint();
		setVisible(true);
		fullScreen = true;
		
	}
	
	//http://gpsnippets.blogspot.com/2007/08/toggle-fullscreen-mode.html
	public void desetFullScreen() {
		setVisible(false);
		dispose();
		gd.setFullScreenWindow(null);
		setUndecorated(false);
		repaint();
		setVisible(true);
		fullScreen = false;
	}
	
	public boolean isFullScreen() {
		return fullScreen;
	}
	public void setFullScreen(boolean fullScreen) {
		this.fullScreen = fullScreen;
	}
	
	public void setGamePanelController(GamePanelController gamePanelController) {
		this.gamePanelController = gamePanelController;
	}
	
	public void setMenuController(MenuController menuController) {
		
		this.menuController = menuController;
	}
}
